home *** CD-ROM | disk | FTP | other *** search
- Path: howland.reston.ans.net!usc!usc!not-for-mail
- From: wawda@alcor.usc.edu (Abu Wawda)
- Newsgroups: comp.lang.c
- Subject: What is &Variable (declared as: char Variable[10])?
- Date: 25 Feb 1996 14:53:53 -0800
- Organization: University of Southern California, Los Angeles, CA
- Sender: wawda@alcor.usc.edu
- Distribution: world
- Message-ID: <4gqpa1$3h9@alcor.usc.edu>
- NNTP-Posting-Host: alcor.usc.edu
-
- I'm having trouble understanding what the address of a static array
- is. For example, if I declare a variable called myarray as:
- char myarray[10];
- then what could &myarray possibly mean? myarray is not a pointer, so
- &myarray could not possibly be the address of the variable myarray
- (like it would be if I did char* myarray and then asked for &myarray).
-
- Functions such as scanf() allow the following:
-
- char myarray[10];
-
- scanf("%s",&myarray);
-
- but I don't understand what scanf() could possibly be taking in the
- second parameter. It can't be: char** since myarray is not a
- pointer. I CAN understand how the following would work:
-
- char* myarray;
-
- myarray = (char*) malloc(10);
- scanf("%s",&myarray);
-
- Then scanf() is simply taking a char** (pointer to a character
- pointer, or in other words the address of the pointer myarray) in its
- second paremeter. However, if I write my own function like this:
-
- void func(char** p)
- {
- // do something here
- }
-
- I cannot pass &myarray if I declare it as: char myarray[10]. So how do
- this work? Thanks in advance,
-
- Abu Wawda
- wawda@scf.usc.edu
-